package com.huilian.iotbox.admin.wap.service.impl;

import com.huilian.iotbox.admin.wap.dao.PushConfigItemDao;
import com.huilian.iotbox.admin.wap.service.PushConfigItemService;
import com.huilian.iotbox.data.common.ServerResponse;
import com.huilian.iotbox.data.dto.PushConfigItemDto;
import com.huilian.iotbox.data.vo.PushConfigItemVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;

/**
 * @author LinYinDong
 * @date 2024/1/9 15:35
 */
@Service
public class PushConfigItemServiceImpl implements PushConfigItemService {
    @Resource
    private PushConfigItemDao pushConfigItemDao;

    @Override
    public ServerResponse editOnePushConfigItem(PushConfigItemDto pushConfigItemDto) {
        PushConfigItemVo pushConfigItemVo = pushConfigItemDao.getOnePushConfigItemByUserIdAndPushConfigId(pushConfigItemDto);
        if (StringUtils.isEmpty(pushConfigItemVo)) {
            //添加
            pushConfigItemDao.insert(pushConfigItemDto);
        } else {
            //修改
            pushConfigItemDao.update(pushConfigItemDto);
        }
        return ServerResponse.createBySuccess();
    }
}
